/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package bean;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import oracle.jdbc.OracleDriver;

/**
 *
 * @author Boriz
 */
public class DataBaseConnection {
//
//    private static String jdbcURL = "jdbc:Oracle:thin:@localhost:1521:XE";
//    private static String user = "hr";
//    private static String password = "hr";
//    private static Connection connection;

    private static String jdbcURL = "jdbc:Oracle:thin:@172.23.9.185:1521:orcl";
    private static String user = "MHS105314093";
    private static String password = "MHS105314093";
    private static Connection connection;

    public static Connection KoneksiDataBase() throws SQLException {

        if (connection == null) {
            DriverManager.registerDriver(new OracleDriver());
            connection = DriverManager.getConnection(jdbcURL, user, password);
            System.out.println("koneksi berhasil");
        }
        return connection;
    }

    public static void main(String args[]) {
        DataBaseConnection conn = new DataBaseConnection();
        try {
            String query = "select * from rploinformasi";
            java.sql.Statement statement = conn.KoneksiDataBase().createStatement();
            java.sql.ResultSet result = statement.executeQuery(query);

            while (result.next()) {
                System.out.println("namapaket : " + result.getString("tittle"));
                System.out.println("harga  : " + result.getString("nama"));
//                System.out.println("status : " + result.getString("status"));

            }
            statement.close();
        } catch (Exception ex) {
            System.out.println("message: " + ex.getMessage());
        }
    }
}



